﻿#region imports

using System;
using System.Collections.Generic;
using Codeplex.ODataTFS.Model.Entities;
using Codeplex.ODataTFS.Model.Serialization;

#endregion

namespace Codeplex.ODataTFS.Model.Repositories
{
	public class QueryRepository
	{
		private readonly TFSQueryProxy _proxy;

		public QueryRepository(TFSQueryProxy proxy)
		{
			_proxy = proxy;
		}

		public Query GetOne(string id)
		{
			Guid queryId;
			if (!Guid.TryParse(id, out queryId))
			{
				throw new ArgumentException("The parameter id should be a GUID", "id");
			}

			return _proxy.GetQuery(queryId);
		}

		public IEnumerable<Query> GetQueriesByProject(string name)
		{
			return _proxy.GetQueriesByProject(name);
		}

		public IEnumerable<Query> GetAll()
		{
			return _proxy.GetQueriesByProjectCollection();
		}
	}
}
